package stringdispose;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringMatching {
	
	 public static boolean intMatch(String s){
		 String regex = "^[0-9]+$";
		 
		 Matcher m = myMatcher(regex , s);
		 
		 return m.find();
	 }
     
	 
	 public static boolean nameMatch(String s){
         String regex = "^[a-zA-Z]+";
		 
		 Matcher m = myMatcher(regex , s);
		 
		 return m.find();
		 
		 
	 } 
	
	 
	 public static boolean emailMatch(String s){
         String regex = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";
		 
		 Matcher m = myMatcher(regex , s);
		 
		 return m.find();
		 
	 } 
	 
	 
	 public static boolean dateMatch(String s){
         String regex = "^((19)\\d{2})|((200)[0-9]|(201)[0-7])([-/]\\d{2}){2}$";
		 
		 Matcher m = myMatcher(regex , s);
		 
		 return m.find();
		 
	 } 
	 
	 public static boolean sexMatch(String s){
         String regex = "(female)|(male)";
		 
		 Matcher m = myMatcher(regex , s);
		 
		 return m.find();
		 
	 } 
	 
	 
	 
	 public static Matcher myMatcher(String regex, String s){
    	 Pattern  p = Pattern.compile(regex);
    	 Matcher m = p.matcher(s);
    	 
    	 return m;
     } 
	 
	 public static boolean myMatcherReturBoolean(String regex, String s){
    	 Pattern  p = Pattern.compile(regex);
    	 Matcher m = p.matcher(s);
    	 
    	 return m.find();
     } 
}
